<template>
	<view class="content">
		<image :src="baseUrl+'/img/juanjiahui/banquet2.jpg'" class="head"></image>
		<view class="selectBox">
			<view class="line"></view>
			<text class="selectLabel">私宴点餐</text>
		</view>
		<view class="orderInfoBox">
			<view class="item">
				<view class="dot"></view>
				<text class="left">餐 厅:</text>
				<text class="right">{{restaurantValue}}</text>
				<uni-section class="selectetime">
					<uni-data-select v-mode="restaurantValue" :localdata="restaurantArr" @change="changeRestaurant" />
					</uni-data-select>
				</uni-section>
			</view>
			<view class="item">
				<view class="dot"></view>
				<text class="left">菜 系:</text>
				<text class="right">{{cuisineValue}}</text>
				<uni-section class="selectetime">
					<uni-data-select v-mode="cuisineValue" :localdata="cuisineArr" @change="changeCuisine" />
					</uni-data-select>
				</uni-section>
			</view>
			<view class="item">
				<view class="dot"></view>
				<text class="left">餐 标:（根据金额配置菜品）</text>
				<input type="text" class="right" placeholder="请输入人均餐标金额" v-model="money"/>
			</view>
			<view class="item" style="flex-direction: column;align-items: baseline;">
				<text class="left">备注：</text>
				<textarea v-model="notes" placeholder="留言您的特殊要求" class="note"/>
			</view>
		</view>
		<view class="orderInfoBox">
			<view class="item" style="align-items: center;">
				<view class="line1" style="margin-left: -40rpx;"></view>
				<text class="left" style="font-size: 28rpx;">个人信息：</text>
			</view>
			<view class="item">
				<view class="dot"></view>
				<text class="left">姓 名：</text>
				<input type="text" class="right" placeholder="请输入姓名" v-model="name"/>
			</view>
			<view class="item">
				<view class="dot"></view>
				<text class="left">房间号：</text>
				<input type="text" class="right" placeholder="请输入房间号" v-model="fanghao"/>
			</view>
			<view class="item">
				<view class="dot"></view>
				<text class="left">联系方式 ：</text>
				<input type="text" class="right" placeholder="请输入您的联系方式" v-model="tel" maxlength="11"/>
			</view>
		</view>
		<view class="cartBox">
			<text class="totalLabel">合计：</text>
			<text class="totalPrice">￥{{totalMoney}}</text>
			<view class="submit" @click="submit">
				提交预约
			</view>
		</view>
	</view>
</template>
<script>
	import {
		add,
		subtract,
		multiply,
		divide
	} from '@/common/mathUtils.js';
	export default {
		data() {
			return {
				baseUrl: this.$baseUrl,
				restaurantValue:'请选择',
				restaurantArr:[],
				cuisineValue:'请选择',
				cuisineArr:[],
				money:'',
				totalMoney:0,
				notes:'',
				name:'',
				fanghao:'',
				tel:'',
				info:'',
			}
		},
		onLoad() {
			this.info = this.$store.state.tempData;
			this.$store.commit('clearTempData');
			// 查询餐厅和菜系 1餐厅 2菜系
			this.$request.get('extension_list?venue_id=1&type=1').then(res => {
				this.restaurantArr = res.data.data.map((item, index) => ({
				  value: index,
				  text: item.name
				}));
			})
			this.$request.get('extension_list?venue_id=1&type=2').then(res => {
				this.cuisineArr = res.data.data.map((item, index) => ({
				  value: index, 
				  text: item.name
				}));
			})
		},
		watch: {
			money(newVal, oldVal) {
				this.totalMoney = multiply(newVal, this.info.num);
			}
		},
		methods: {
			submit() {
				if (!this.restaurantValue || this.restaurantValue=='请选择') {
					return this.$toast("请选择餐厅");
				}
				if (!this.cuisineValue || this.cuisineValue=='请选择') {
					return this.$toast("请选择菜系");
				}
				if (!this.money) {
					return this.$toast("请输入餐标金额");
				}
				if (!this.name) {
					return this.$toast("请输入姓名");
				}
				if (!this.fanghao) {
					return this.$toast("请输入房间号");
				}
				if (!this.tel || !(/^1[3|4|5|6|8|7|9][0-9]\d{8}$/.test(this.tel))) {
					return this.$toast('请输入正确的联系方式');
				}
				this.$store.commit('setTempData', this.$data);
				this.$navto.navto("/pages/juanjiahui_banquet_order/juanjiahui_banquet_order")
			},
			changeRestaurant(e) {
				console.log("e:", e);
				this.restaurantValue = this.restaurantArr[e].text;
			},
			changeCuisine(e) {
				console.log("e:", e);
				this.cuisineValue = this.cuisineArr[e].text;
			}
		}
	}
</script>
<style lang="scss" scoped>
	.cartBox {
		position: fixed;
		z-index: 3;
		bottom: 0;
		width: 100%;
		height: 130rpx;
		background-color: #ffffff;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		padding-left: 40rpx;
		padding-right: 40rpx;
		justify-content: space-between;
		padding-bottom: 20rpx;
		border-top: 1rpx solid #f0f0f0;
	
		.totalPrice {
			color: #121212;
			font-weight: 700;
			font-size: 34rpx;
			letter-spacing: 2rpx;
		}
	
		.totalLabel {
			font-weight: 700;
			font-size: 20rpx;
			color: #121212;
		}
	
		.submit {
			width: 420rpx;
			height: 80rpx;
			border-radius: 40rpx;
			background: #121212;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: 700;
			font-size: 28rpx;
			color: #FFFFFF;
			letter-spacing: 5rpx;
			margin-left: auto;
		}
	}
	.orderInfoBox {
		box-sizing: border-box;
		background-color: #fff;
		border-top: 25rpx solid #f0f0f0;
		.item {
			width: 670rpx;
			position: relative;
			padding-top: 45rpx;
			padding-bottom: 45rpx;
			border-bottom: 1rpx solid #121212;
			display: flex;
			justify-content: space-between;
			font-size: 26rpx;
			margin-left: 40rpx;
			align-items: center;

			.note {
				width: 100%;
				height: 200rpx;
				margin-top: 20rpx;
			}

			.right {
				font-weight: 500;
				font-size: 26rpx;
				color: #121212;
				display: flex;
				margin-left: auto;
				text-align: right;
				align-items: center;
			}

			.left {
				font-weight: 700;
				font-size: 26rpx;
				color: #121212;
			}
		}

		.item:last-child {
			border: none;
		}
	}

	.selectBox {
		width: 100%;
		height: 110rpx;
		background-color: #000;
		border-radius: 20rpx 20rpx 0 0;
		border-top: 1rpx solid #717171;
		margin-top: -30rpx;
		position: relative;
		display: flex;
		align-items: center;

		.selectLabel {
			font-weight: 700;
			font-size: 26rpx;
			color: #FFFFFF;
			letter-spacing: 5rpx;
			margin-left: 40rpx;
		}
	}

	::v-deep .uni-select {
		border: none;
	}
	::v-deep .uni-icons{
		display: none;
	}
	::v-deep .uni-select__input-box {
		opacity: 0 !important;
	}
	.selectetime {
		position: absolute;
		right: 0rpx;
		width: 200rpx;
		height: 100%;
	}
	.dot{
		width: 6rpx;
		height: 6rpx;
		border-radius: 50%;
		background-color: #000;
		margin-right: 25rpx;
	}
	.line1 {
		width: 4rpx;
		height: 20rpx;
		background: #ff6d5c;
		position: absolute;
		left: 0;
	}

	.line {
		width: 4rpx;
		height: 20rpx;
		background: #ff6d5c;
	}

	.head {
		width: 100%;
		height: 200rpx;
	}

	.content {
		width: 100%;
		min-height: 100vh;
		background-color: #f0f0f0;
		padding-bottom: 200rpx;
	}
</style>